#pragma once

#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
#include <string>

class InetAddr
{
public:
    InetAddr(struct sockaddr_in sock)
        :_sock(sock)
    {}

    std::string Ip()
    {
        return inet_ntoa(_sock.sin_addr);
    }

    uint16_t Port()
    {
        return ntohs(_sock.sin_port);
    }

    std::string PrintDebug()
    {
        std::string info = "[";
        info += Ip();
        info += ":";
        info += std::to_string(Port());
        info += "]";
        info += "# ";

        return info;
    }

    ~InetAddr()
    {}

private:
    struct sockaddr_in _sock;
};